package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.ProductionOrder;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.WorkReport;
import com.qidianit.mes.pro.service.WorkReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author:WuJingLei
 * @ Date: 2025/9/26 -18:03
 */
@RestController
@RequestMapping("/workReport")
public class WorkReportController {
    @Autowired
    private WorkReportService workReportService;

    @GetMapping("/page")
    public Result<PageInfo<WorkReport>> page(WorkReport workReport,
                                                  @RequestParam(defaultValue = "1") int pageNum,
                                                  @RequestParam(defaultValue = "10") int pageSize){
        return workReportService.queryWorkReports(workReport,pageNum,pageSize);
    }

    @GetMapping("/{id}")
    public Result<WorkReport> queryById(@PathVariable Long id){
        return workReportService.getById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody WorkReport workReport){
        return workReportService.updateWorkReport(workReport);
    }

    @PostMapping("/add")
    public Result<WorkReport> add(@RequestBody WorkReport workReport){
        return workReportService.saveWorkReport(workReport);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return workReportService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result delete(Long[] id){
        return workReportService.batchDelete(id);
    }
}
